home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / EDO Hack / source code / sources / ReturnAppName.c < prev    next >
Encoding:
Text File  |  1997-06-28  |  1.1 KB  |  35 lines  |  [TEXT/CWIE]

  1. // --------------------------------------------------------------------------------------
  2. //  ReturnAppName.c
  3. //
  4. //  Written by Don Arbow and Marc A. Raiser, EveryDay Objects, Inc.
  5. //     in one day - June 26, 1997
  6. // --------------------------------------------------------------------------------------
  7.  
  8. #include <Processes.h>
  9. #include <Files.h>
  10.  
  11. #include "ReturnAppName.h"
  12.  
  13. OSErr ReturnAppName(Str255 fileName) {
  14.  
  15.     register int        i;
  16.     ProcessInfoRec        thisProcess;
  17.     ProcessSerialNumber    process;
  18.     FSSpec                myFS;
  19.     OSErr               err = noErr;
  20.     short               fileNameLen = fileName[0];
  21.     
  22.     thisProcess.processAppSpec = &myFS;                /* Aim pointer at our storage */
  23.     thisProcess.processInfoLength = sizeof(ProcessInfoRec);    /* Store record size */
  24.     thisProcess.processName = (unsigned char *) NewPtr(32);    /* Allocate room for the name */
  25.     process.highLongOfPSN = 0;                        /* Clear out process serial number */
  26.     process.lowLongOfPSN = kCurrentProcess;
  27.  
  28.     err = GetProcessInformation(&process, &thisProcess);
  29.     
  30.     if (err == noErr) {
  31.         BlockMoveData(myFS.name + 1, fileName + fileNameLen + 1, *(myFS.name));
  32.         fileName[0] += myFS.name[0];
  33.     }
  34.     return err;
  35. }